package com.gz.WeChatSys.dto;

import java.io.Serializable;

/**
 * @Author: Zr
 * @Description:
 * @Date: 2018/9/29 15:49
 * @Modified By:
 */
public class ResultDTO<T> implements Serializable {
    private T data;
    private int status = -1;
    private String msg;

    public static ResultDTO isOk(){
        return new ResultDTO().status(1).msg("success");
    }

    public static ResultDTO isFail(){
        return new ResultDTO().msg("fail");
    }

    public static ResultDTO isFail(Throwable e){
        return new ResultDTO().msg(e);
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public ResultDTO data(T data){
        this.setData(data);
        return this;
    }
    public ResultDTO status(int status) {
        this.setStatus(status);
        return this;
    }

    public ResultDTO msg(Throwable e) {
        this.setMsg(e.toString());
        return this;
    }
    public ResultDTO msg(String msg){
        this.setMsg(msg);
        return this;
    }
}
